package org.exaple.mp.plugins;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import org.apache.ibatis.plugin.Invocation;
import org.exaple.mp.intercept.QueryInterceptor;

/**
 * 查询拦截器执行器
 *
 * <p>
 * 目的：抽取此方法是为了后期方便同步更新 {@link CustomPaginationInterceptor}
 * </p>
 *
 */
public class QueryInterceptorExecutor {

	/**
	 * 执行查询拦截器
	 *
	 * @param interceptors 拦截器
	 * @param invocation   拦截器参数
	 */
	static void exec(QueryInterceptor[] interceptors, Invocation invocation) throws Throwable {
		if (ObjectUtils.isEmpty(interceptors)) {
			return;
		}
		for (QueryInterceptor interceptor : interceptors) {
			interceptor.intercept(invocation);
		}
	}

}
